<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>抽奖管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
	<c:if test="${user.id  eq 1 }">
		<script type="text/javascript">
			function toLottery(id,uname){
				mobile = $('#mobile'+id).val();
				if(mobile =='' || mobile.length==0){
					alert("请输入手机号");
					return false;
				}
				url = '${ctx}/wechat/lottery/alottery?id='+id+'&uname='+uname+'&mobile='+mobile;
				$.post(url,{},function(data){
					$('#result'+id).html(data);
				});
			}				
								
		</script>				
	</c:if>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/wechat/lottery/activityList">奖品列表</a></li>
		<shiro:hasPermission name="wechat:lottery:edit"><li><a href="${ctx}/wechat/lottery/activityForm">奖品添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="lottery" action="${ctx}/wechat/lottery/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>名称 ：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<shiro:hasPermission name="sys:user:edit"><th>所属商家</th></shiro:hasPermission>
		<th>名称</th>
		<th>类型</th><th>中奖机率</th><th>数量</th><th>备注</th><shiro:hasPermission name="wechat:lottery:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="lottery">
			<tr>
				<shiro:hasPermission name="sys:user:edit"><td>${lottery.user.name}</td></shiro:hasPermission>
				<td><a href="${ctx}/wechat/lottery/activityForm?id=${lottery.id}">${lottery.name}</a></td>
				<td><c:if test="${lottery.type eq 1}">会员抽奖</c:if> <c:if test="${lottery.type eq 2}">商家抽奖</c:if> </td>
				<td>${lottery.percent}%</td>
				<td>${lottery.peramount}</td>
				<td>${lottery.remarks}</td>
				<shiro:hasPermission name="wechat:lottery:edit"><td>
    				<a href="${ctx}/wechat/lottery/activityForm?id=${lottery.id}">修改</a>
					<a href="${ctx}/wechat/lottery/delete?id=${lottery.id}" onclick="return confirmx('确认要删除该抽奖吗？', this.href)">删除</a>
					<c:if test="${user.id  eq 1 }">

								<!-- Modal -->
								<div id="myModal${lottery.id }" class="modal hide fade" tabindex="-1"
									role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">×</button>
										<h3 id="myModalLabel">指定抽奖</h3>
									</div>
									<div class="modal-body">
										<p><input name="mobile" type="text" id="mobile${lottery.id }"/> </p>
										<p><span id="result${lottery.id }"></span></p>
									</div>
									<div class="modal-footer">
										<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
										<button class="btn btn-primary" onclick="toLottery('${lottery.id }','${lottery.user.loginName }');">提交</button>
									</div>
								</div>


								<a href="#myModal${lottery.id }"  role="button" data-toggle="modal">指抽</a>
						
					</c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
